   package org.testis.guiappsmodule.services;

import org.testis.data.TestStepException;
import org.testis.data.TestStepResultType;
import org.testis.services.AtofModuleAction;
import org.testis.services.AtofModuleActionFactory;
import org.testis.testdriver.AtofEnumaration.AtofGuiAppsModuleAction;

/**
 *
 * @author nurhat
 */
public class GuiAppsModuleActionFactory extends AtofModuleActionFactory
{

    @Override
    public AtofModuleAction getActionObject(String actionType)
    {
        AtofGuiAppsModuleAction action;
        try {
            action = AtofGuiAppsModuleAction.valueOf(actionType);
        } catch (IllegalArgumentException ex) {

            throw new TestStepException(TestStepResultType.MISTAKE,
                                        "Action type given " + actionType +
                                        " not found for Gui Application ..." +
                                        ex.getMessage());
        }
        AtofModuleAction actionObj = null, actionObj2, actionObj3;
        actionObj = new GuiAppsExecuteAction();
        if (action ==
            AtofGuiAppsModuleAction.GuiAppsExecuteAndExitCodeVerification) {
            actionObj2 = new GuiAppsExitCodeVerificationAction();
            actionObj.setSuccessor(actionObj2);
        }
        else if (action ==
            AtofGuiAppsModuleAction.GuiAppsExecuteAndOutputVerification) {
            actionObj2 = new GuiAppsOutputVerificationAction();
            actionObj.setSuccessor(actionObj2);
        }
        else if (action ==
            AtofGuiAppsModuleAction.GuiAppsExecuteAndVerifyAll) {
            actionObj2 = new GuiAppsOutputVerificationAction();
            actionObj.setSuccessor(actionObj2);
            actionObj3 = new GuiAppsExitCodeVerificationAction();
            actionObj2.setSuccessor(actionObj3);
        }
        else if (action ==
            AtofGuiAppsModuleAction.GuiAppsExecute) {
            return actionObj;
        }
        else {
            throw new TestStepException(TestStepResultType.MISTAKE,
                                        "Action type given " + actionType +
                                        " not found for Gui Application ...");
        }
        return actionObj;

    }
}